package com.zmn.oms.common.constant;

import com.zmn.common.constant.GlobalConsts;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * app相关常量
 *
 * @author xiangyang
 * @since 2020-06-09
 */
@Component
@Data
public class AppConsts {

    /**
     * app平台
     */
    public final static int APP_OS_ANDROID = 1; // 安卓
    public final static int APP_OS_IOS = 2;     // IOS


    /**
     * app弹框提示状态码
     */

    /**
     * 支付标志
     */
    public final static int ORDER_PAY_FLAG_NONE = 0;   // 无须支付
    public final static int ORDER_PAY_FLAG_UNPAID = 1; // 未支付
    public final static int ORDER_PAY_FLAG_PAID = 2;   // 已支付
    public final static int APP_PAY_FLAG_ALERT_USER_PAY = 3; // 提示用户支付
    public final static int APP_PAY_FLAG_CHANNEL_PRICE = 4;    // 服务项价格不满足渠道配置
    public final static int APP_PAY_FLAG_POSITION = 5;         // 距离过远
    public final static int APP_PAY_FLAG_THIRD_PAY= 6;         // 是否特殊支付渠道
    public final static int APP_PAY_FLAG_VISIT_USER= 7;         // 扫码用户支付(支付消息发送成功)
    public final static int APP_PAY_FLAG_VISIT_USER_FALSE= 8;         // 扫码用户支付(消息发送失败)
    public final static int APP_PAY_FLAG_CHANNEL_GUIDE = 9;         // 提示渠道需要支付指引
    public final static int APP_PAY_FLAG_CHANNEL_GUIDE_NO_EXPLAIN = 10;         // 无支付说明提示渠道需要支付指引

    /**
     * 支持师傅形象照片检测的平台（上门后，需要传形象照片流程）
     */
    public final static List MASTER_PICTURE_CHECK_PLAT = Arrays.asList(GlobalConsts.PLAT_MARK_ZMN, GlobalConsts.PLAT_MARK_CNHB);

    /**
     * APP操作类型
     */
    public final static int OPERATE_TYPE_TAKE = 1;   // 领单
    public final static int OPERATE_TYPE_CONTACT = 2;   // 联系用户
    public final static int OPERATE_TYPE_VISIT = 3;   // 上门
    public final static int OPERATE_TYPE_COMPLETE = 4;   // 完成服务

    /**
     * APP操作类型
     */
    public final static int OPERATE_TEXT_TYPE_DUTY_TIME = 20;   // 预约时间
    public final static int OPERATE_TEXT_TYPE_TAKE = 41;   // 领单
    public final static int OPERATE_TEXT_TYPE_PLAN_TRIP = 43;   // 计划行程
    public final static int OPERATE_TEXT_TYPE_CONTACT = 45;   // 联系用户
    public final static int OPERATE_TEXT_TYPE_DEPART = 48;   // 出发
    public final static int OPERATE_TEXT_TYPE_VISIT = 51;   // 上门
    public final static int OPERATE_TEXT_TYPE_VISIT_VISIT = 55;   // 多次上门-上门
    public final static int OPERATE_TEXT_TYPE_VISIT_DEPART = 56;   // 多次上门-出发
    public final static int OPERATE_TEXT_TYPE_COMPLETE = 61;   // 完成服务


    /**
     * APP PUSH_MESSAGE_ID
     */
    public static int MSG_ID_TAKE_ON_TIME;   // 领单准时
    public static int MSG_ID_TAKE_OUT_TIME;   // 领单超时
    public static int MSG_ID_CONTACT_ON_TIME;   // 联系准时
    public static int MSG_ID_CONTACT_OUT_TIME;   // 联系超时
    public static int MSG_ID_VISIT_ON_TIME;   // 上门准时
    public static int MSG_ID_VISIT_OUT_TIME;   // 上门超时
    public static int MSG_ID_COMPLETE_ON_TIME;   // 完成准时
    public static int MSG_ID_COMPLETE_OUT_TIME;   // 完成超时

    @Value("${app.message-id.takeOnTime:0}")
    public void setMsgIdTakeOnTime(int msgIdTakeOnTime) {
        MSG_ID_TAKE_ON_TIME = msgIdTakeOnTime;
    }

    @Value("${app.message-id.takeOutTime:0}")
    public void setMsgIdTakeOutTime(int msgIdTakeOutTime) {
        MSG_ID_TAKE_OUT_TIME = msgIdTakeOutTime;
    }

    @Value("${app.message-id.contactOnTime:0}")
    public void setMsgIdContactOnTime(int msgIdContactOnTime) {
        MSG_ID_CONTACT_ON_TIME = msgIdContactOnTime;
    }

    @Value("${app.message-id.contactOutTime:0}")
    public void setMsgIdContactOutTime(int msgIdContactOutTime) {
        MSG_ID_CONTACT_OUT_TIME = msgIdContactOutTime;
    }

    @Value("${app.message-id.visitOnTime:0}")
    public void setMsgIdVisitOnTime(int msgIdVisitOnTime) {
        MSG_ID_VISIT_ON_TIME = msgIdVisitOnTime;
    }

    @Value("${app.message-id.visitOutTime:0}")
    public void setMsgIdVisitOutTime(int msgIdVisitOutTime) {
        MSG_ID_VISIT_OUT_TIME = msgIdVisitOutTime;
    }

    @Value("${app.message-id.completeOnTime:0}")
    public void setMsgIdCompleteOnTime(int msgIdCompleteOnTime) {
        MSG_ID_COMPLETE_ON_TIME = msgIdCompleteOnTime;
    }

    @Value("${app.message-id.completeOutTime:0}")
    public void setMsgIdCompleteOutTime(int msgIdCompleteOutTime) {
        MSG_ID_COMPLETE_OUT_TIME = msgIdCompleteOutTime;
    }

    public static String getOperateName(Integer id) {
        switch (id) {
            case OPERATE_TYPE_TAKE:
                return "领单";
            case OPERATE_TYPE_CONTACT:
                return "联系";
            case OPERATE_TYPE_VISIT:
                return "上门";
            case OPERATE_TYPE_COMPLETE:
                return "完成";
            default:
                return "未知操作";
        }
    }

    public static String getOperateText(Integer id) {
        switch (id) {
            case OPERATE_TEXT_TYPE_TAKE:
                return "领单";
            case OPERATE_TEXT_TYPE_CONTACT:
                return "联系用户";
            case OPERATE_TEXT_TYPE_VISIT:
                return "上门";
            case OPERATE_TEXT_TYPE_COMPLETE:
                return "完成服务";
            case OPERATE_TEXT_TYPE_PLAN_TRIP:
                return "计划行程";
            case OPERATE_TEXT_TYPE_DUTY_TIME:
                return "预约时间";
            case OPERATE_TEXT_TYPE_DEPART:
                return "出发";
            case OPERATE_TEXT_TYPE_VISIT_VISIT:
                return "上门";
            case OPERATE_TEXT_TYPE_VISIT_DEPART:
                return "出发";
            default:
                return "未知操作";
        }
    }


    public static Integer getOnTimeMsgId(Integer id) {
        switch (id) {
            // TaskTODO 2022/9/15 11:25：【领单准时】场景暂时不发消息。
//            case OPERATE_TYPE_TAKE:
//                return MSG_ID_TAKE_ON_TIME;
            case OPERATE_TYPE_CONTACT:
                return MSG_ID_CONTACT_ON_TIME;
            case OPERATE_TYPE_VISIT:
                return MSG_ID_VISIT_ON_TIME;
            case OPERATE_TYPE_COMPLETE:
                return MSG_ID_COMPLETE_ON_TIME;
            default:
                return null;
        }
    }


    public static Integer getOutTimeMsgId(Integer id) {
        switch (id) {
            case OPERATE_TYPE_TAKE:
                return MSG_ID_TAKE_OUT_TIME;
            case OPERATE_TYPE_CONTACT:
                return MSG_ID_CONTACT_OUT_TIME;
            case OPERATE_TYPE_VISIT:
                return MSG_ID_VISIT_OUT_TIME;
            case OPERATE_TYPE_COMPLETE:
                return MSG_ID_COMPLETE_OUT_TIME;
            default:
                return null;
        }
    }


}
